package acwing._2LanQiao._1Recursion;

import java.util.Scanner;

/**
 * @Project : ProgrammingExercises
 * @Package : ACWing._2LanQiao._1_1Recursion
 * @File : Q0094.java
 * @Author : WangRuoyu
 * @Date : 2023/3/12 19:34
 */

public class Q0094 {
    static int n;
    static int[] remove;
    static int[] read;

    static void f(int k) {
        if (k == n) {
            for (int i = 0; i < read.length; i++) {
                System.out.print(read[i] + 1 + " ");
            }
            System.out.println();
        } else {
            for (int i = 0; i < n; ++i) {
                if (remove[i] == 0) {
                    remove[i] = 1;
                    read[k] = i;
                    f(k + 1);
                    remove[i] = 0;
                }
            }
        }
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        n = scan.nextInt();
        remove = new int[n];
        read = new int[n];
        int k = 0;
        Q0094.f(k);
    }
}


